package com.itheima.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

    public static void main(String[] args) throws IOException {
        //创建服务端对象
        ServerSocket ss = new ServerSocket(6666);
        //接收 客户端的连接  获取到 连接对象
        Socket accept = ss.accept();//阻塞的  等客户端的连接
        //获取输入流
        InputStream is = accept.getInputStream();
        // 读取数据
        int b;
        while ((b =is.read())!=-1){//read() 没有数据我就等
            System.out.println((char)b);
        }
        // 释放资源
        //is.close();
       // accept.close();
        ss.close();

    }
}
